/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.boxin.ims.modules.ad.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

import com.thinkgem.jeesite.common.persistence.BaseDao;
import com.thinkgem.jeesite.common.persistence.BaseDaoImpl;
import com.boxin.ims.modules.ad.entity.Advertisement;

/**
 * 广告DAO接口
 * @author Jakemanse
 * @version 2014-04-18
 */
public interface AdvertisementDao extends AdvertisementDaoCustom, CrudRepository<Advertisement, Long> {

	@Modifying
	@Query("delete from  Advertisement   where id = ?1")
	public int deleteById(Long id);
	
	@Query(" from   Advertisement where id in (select ad_id  from  AdToUser  as a  where  a.user.id = ?1  )and startup=1")
	public  List<Advertisement> findSellerAdList(Long userId);
	
	
	@Query(" from  Advertisement  where 1=1 and advertiser.id = ?1")
	public  List<Advertisement> findMyAdvertisement(Long userId);
	
	
}

/**
 * DAO自定义接口
 * @author Jakemanse
 */
interface AdvertisementDaoCustom extends BaseDao<Advertisement> {

}

/**
 * DAO自定义接口实现
 * @author Jakemanse
 */
@Component
class AdvertisementDaoImpl extends BaseDaoImpl<Advertisement> implements AdvertisementDaoCustom {

}
